﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InstituteManager.Data;
using System.Data;
using System.Data.Objects;

namespace InstituteManager.Bussiness
{
    public static class AwardIssuedBL
    {
        public static List<tbl_AwardIssued> getByAll()
        {
            InstituteManagerEntities InsMana = new InstituteManagerEntities();
            List<tbl_AwardIssued> compe = InsMana.tbl_AwardIssued.ToList();
            return compe;
        }
        public static tbl_AwardIssued getById(int Id)
        {
            InstituteManagerEntities InsMana = new InstituteManagerEntities();
            tbl_AwardIssued com = new tbl_AwardIssued();
            com = InsMana.tbl_AwardIssued.Include("tbl_Competition").Include("tbl_Student").Include("tbl_Posting").First(temp => temp.AwardIssuedId == Id);
            
            return com;
        }

        public static Object getListInfo()
        {
            InstituteManagerEntities InsMana = new InstituteManagerEntities();
            return (from s in InsMana.tbl_AwardIssued.Include("tbl_Award").Include("tbl_Student").Include("tbl_Posting") select new { AwardIssuedId = s.AwardIssuedId, CompetitionName = s.tbl_Posting.tbl_Competition.CompetitionName, StudentName = s.tbl_Posting.tbl_Student.StudentName, PostingName = s.tbl_Posting.PostingName , AwardName = s.tbl_Posting.tbl_Competition.tbl_Award.AwardName });
        }

        public static List<tbl_Competition> getCompetitionAwarded()
        {
            InstituteManagerEntities InsMana = new InstituteManagerEntities();
            return (from sc in InsMana.tbl_AwardIssued.Include("tbl_Posting").Include("tbl_Student").Include("tbl_Competition").Include("tbl_Award") select sc.tbl_Posting.tbl_Competition).ToList();
        }
    }
}
